package com.nami.gate.router.middleware.mq.consumer.listener;

import com.nami.gate.external.basic.constants.UpTopicConst;
import com.nami.gate.router.middleware.mq.MqSender;
import com.nami.im.network.model.enums.MqTopicConst;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class RouterLoginListenerImpl extends AbstractConsumer {

    private static final Logger log = LoggerFactory.getLogger(RouterLoginListenerImpl.class);

    private MqSender sender;

    public RouterLoginListenerImpl(MqSender sender) {
        this.sender = sender;
    }

    @Override
    public String getTopicName() {
        return MqTopicConst.CONNECT;
    }

    @Override
    public void onMessage(byte[] body) {
        try {
            long start = System.currentTimeMillis();

            log.info("router publish msg topic={}", UpTopicConst.LOGIN_TOPIC);
            sender.send(UpTopicConst.LOGIN_TOPIC,  new byte[]{});
            log.info("router服务处理登录消耗:{}ms", System.currentTimeMillis() - start);
        } catch (Exception ex) {
            ex.printStackTrace();
            log.error("router publish msg error", ex);
        }

    }



}
